<template>
  <div class="f2bpm-page-layout">
    <div style="width: 100%; margin: 0;">
      <div class="wf-box">
        <div class="wf-box-in">
          <div class="wf-pop-in">
            <table>
              <tr>
                <td>
                  <div id="AssistActorListContainer" v-html="assistActorHtml" class="ActorListContainer" style="background-color: #fff; padding: 5px 5px; width: 450px; height: 200px; vertical-align: top; text-align: left; overflow-y: auto">
                  </div>
                </td>
              </tr>
            </table>
          </div>
          <div id="AproOpinionDiv" v-show="isShowOpinion">
            <div class="wf-pop-tit" style="height: 55px;">
              <span class="ml10">转办意见：<i v-if="wfContext.IsMustAddOpinion" class="red">*</i></span>  
              <el-select value="" size="mini" @change="aproOpinionChange" style="width: 250px;" filterable placeholder="请选择">
                <el-option v-for="item in aproOpinionData" :label="item.text" :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div class="wf-pop-in p3">
              <el-input v-model="data.hidOpinion" maxlength="1000" show-word-limit type="textarea" :rows="3" placeholder="请填写审核意见" />
            </div>
          </div>
          <div id="ActorSelectedDiv" style="display: none">
            <input id="hidSelectUsers" name="hidSelectUsers" actorselected="SelectUsers" type="hidden" value="" />
            <input id="hidSelectedActivityType" name="hidSelectedActivityType" actorselected="SelectedActivityType" type="hidden" value="" />
            <input id="hidSelectedActivityJson" name="hidSelectedActivityJson" actorselected="SelectedActivityJson" type="hidden" value="" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    watch: {
      treeFilterText(val) {
        this.$refs.mytree.filter(val);
      }
    }
    , computed: {
      countGridHeight() {
        return $(document).height() - global_datagridHeightDiff;
      }
      , rotateIcon() {
        return this.isCollapsed ? 'fa fa-angle-double-right' : 'fa fa-angle-double-left';
      }
    }
    , created() {
      var that = this;
      var taskId = Object.toQueryString("taskId") || "";
      var formAction = Object.toQueryString("formAction") || "";
      var parmsStr = Object.toQueryString("parms");
      var parms = {};
      if (parmsStr) {
        parmsStr = decodeURIComponent(parmsStr);
        parms = eval("(" + parmsStr + ")");
      }
      window.parms = parms;
      
      that.taskId = taskId;
      that.formAction = formAction;
      let currUser =  that.$store.getters.getState.author;

      //加载页面Model数据
      var jsonData = Object.toAjaxJson("/workflow/sendActor/", "getAssistActorSelectData", { taskId: taskId })
      console.info(jsonData);
      that.wfContext = jsonData.wfContext;
      that.assistActorHtml = jsonData.assistActorHtml;
      that.isShowOpinion = !that.wfContext.IsShowFormOpinion;
      if (that.isShowOpinion) {
        that.sqlkeyArray[0].parm = "opinionType:0,creatorId:" + currUser.userId;
        FUI.Form.initailSqlKeyComboBox(this);
      }
    }
    , data() {
      return {
        //url参数
        appId: "",
        wiid: "",
        taskId: "",
        formAction: null,
        //======数据============
        isShowOpinion: false,
        wfContext: {},
        circulatedActorHtml: '',
        data: {
          hidSelectUsers: '',
          hidOpinion: ''
        },

        aproOpinionData: [],
        sqlkeyArray: [{
          dataField: 'aproOpinionData',
          sqlkey: 'CB_ProcessOpinion_Select',
          flag: '1',
          parm: ""
        }
        ]
      };
    },

    methods: {
      collapsedSider() {
        this.isCollapsed = this.isCollapsed ? false : true;
      }
      , aproOpinionChange(v) {
        this.data.hidOpinion = this.data.hidOpinion + v;
      }
      , selectorUserTextValue(inputKey, inputName, passParm, singleSelect, keyName, width, height) {
        var that = this;
        WF.SelectorDialog.selectorUserTextValue(that, inputKey, inputName, passParm, singleSelect, keyName, width, height)
      }
      , getResult() {
        var that = this;
        var selectedUser = $("#hidSelectUsers").val();
        var selectedActivityType = "";
        if (selectedUser == "") {
          FUI.layuiLayer.msg(null, "请选传阅人！");
          return false;
        }
        that.data.hidSelectUsers = $("#hidSelectUsers").val();
        return that.data;
      }
    }
    , mounted() {
	  window.myvm=this;
      loadPageExtends();
      selectedFirstNextActivity();
    }
  }

  window.getResult = function () {
    return myvm.getResult();
  }
  //*****************业务方法*****************
  //**选人方法**
  function loadPageExtends() {
    //选择部门下的所有人员与反选择
    $("#AssistActorListContainer input[levelcode='department']").each(function () {
      $(this).click(function () {
        var dpid = $(this).attr("dpid");
        var activityid = $(this).attr("activityid");
        checkedActivityDepartUsers(activityid, dpid, $(this).is(":checked"), "Assist");
        onSure("Assist");
        setAcitivtyUserSelectCount(activityid, "Assist");
      });
    });
    $(".addRight3").click();
  };
</script>
<style lang="scss" scoped>
    @import url("@/static/css/workflowform.css");
    
  </style>